Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CREATE] server package for HTTP server (#33) #33

Merged
merged 3 commits into from
Jul 13, 2024

Conversation

Nicolas-ggd
Copy link
Contributor

Create server folder and move HTTP server under this directory.

The purpose of this PR is to separate the HTTP server from main.go, i create server/ folder under the pkg/ directory, move Middleware and Routes under server/ direcotry.

Some operation move to pkg/server/config.go, i believe it's a server functionally and nothing have common with main.go

@CyberRoute
Copy link
Owner

Thanks a lot! Much appreciated, will check it out asap

Copy link
Owner

@CyberRoute CyberRoute left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other than troubles created from my gitignore that is not complete (my bad), this looks great to me, thanks a lot

.idea/.gitignore Outdated
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may want to remove the .idea folder, the gitignore is not complete since I develop on linux I didn't bother to add that :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will put .idea folder in .gitignore for future

build/bruter Outdated
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also the build folder to be wiped, that comes from running the make commands

@Nicolas-ggd
Copy link
Contributor Author

other than troubles created from my gitignore that is not complete (my bad), this looks great to me, thanks a lot

okey, i will fix that quickly

@CyberRoute
Copy link
Owner

Just tested it and I will have to look better into since something seems broken...

alessandro@xps:~/Development/bruter$ git pull origin pull/33/head
remote: Enumerating objects: 21, done.
remote: Counting objects: 100% (21/21), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 21 (delta 3), reused 21 (delta 3), pack-reused 0
Unpacking objects: 100% (21/21), 6.36 MiB | 2.67 MiB/s, done.
From github.com:CyberRoute/bruter
 * branch            refs/pull/33/head -> FETCH_HEAD
Updating 9c48e4c..00eabad
Fast-forward
 .idea/.gitignore                                             |   8 ++++++++
 .idea/bruter.iml                                             |   9 +++++++++
 .idea/modules.xml                                            |   8 ++++++++
 .idea/vcs.xml                                                |   6 ++++++
 build/bruter                                                 | Bin 0 -> 12375458 bytes
 cmd/bruter/main.go                                           |   3 ++-
 {cmd/bruter => pkg/server}/concurrency.go                    |   6 ++----
 cmd/bruter/routes.go => pkg/server/config.go                 |  39 +++++++++++++++------------------------
 cmd/bruter/middleware.go => pkg/server/middleware/session.go |   5 ++++-
 pkg/server/routes/routes.go                                  |  17 +++++++++++++++++
 pkg/server/server.go                                         |  22 ++++++++++++++++++++++
 11 files changed, 93 insertions(+), 30 deletions(-)
 create mode 100644 .idea/.gitignore
 create mode 100644 .idea/bruter.iml
 create mode 100644 .idea/modules.xml
 create mode 100644 .idea/vcs.xml
 create mode 100755 build/bruter
 rename {cmd/bruter => pkg/server}/concurrency.go (85%)
 rename cmd/bruter/routes.go => pkg/server/config.go (78%)
 rename cmd/bruter/middleware.go => pkg/server/middleware/session.go (66%)
 create mode 100644 pkg/server/routes/routes.go
 create mode 100644 pkg/server/server.go
alessandro@xps:~/Development/bruter$ go run cmd/bruter/*.go -domain example.com
6:54PM INF Scanning IP 93.184.215.14 OK
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x59816e]

goroutine 13 [running]:
github.com/rs/zerolog.(*Logger).should(0x10?, 0x78?)
	/home/alessandro/go/pkg/mod/github.com/rs/[email protected]/log.go:470 +0xe
github.com/rs/zerolog.(*Logger).newEvent(0x0, 0x3, 0x0)
	/home/alessandro/go/pkg/mod/github.com/rs/[email protected]/log.go:446 +0x36
github.com/rs/zerolog.(*Logger).Error(0xc000197aa0?)
	/home/alessandro/go/pkg/mod/github.com/rs/[email protected]/log.go:348 +0x1a
github.com/CyberRoute/bruter/pkg/server.checkError({0x982440, 0xc00040a040})
	/home/alessandro/Development/bruter/pkg/server/config.go:19 +0x33
github.com/CyberRoute/bruter/pkg/server.RunConfiguration.func3()
	/home/alessandro/Development/bruter/pkg/server/config.go:64 +0x85
github.com/CyberRoute/bruter/pkg/server.RunConcurrently.func1(0x0?)
	/home/alessandro/Development/bruter/pkg/server/concurrency.go:12 +0x4c
created by github.com/CyberRoute/bruter/pkg/server.RunConcurrently in goroutine 1
	/home/alessandro/Development/bruter/pkg/server/concurrency.go:10 +0x48
exit status 2

@Nicolas-ggd
Copy link
Contributor Author

go run cmd/bruter/*.go -domain example.com

wait, i will try one more time to duplicate this scenario

@Nicolas-ggd
Copy link
Contributor Author

Just tested it and I will have to look better into since something seems broken...

alessandro@xps:~/Development/bruter$ git pull origin pull/33/head
remote: Enumerating objects: 21, done.
remote: Counting objects: 100% (21/21), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 21 (delta 3), reused 21 (delta 3), pack-reused 0
Unpacking objects: 100% (21/21), 6.36 MiB | 2.67 MiB/s, done.
From github.com:CyberRoute/bruter
 * branch            refs/pull/33/head -> FETCH_HEAD
Updating 9c48e4c..00eabad
Fast-forward
 .idea/.gitignore                                             |   8 ++++++++
 .idea/bruter.iml                                             |   9 +++++++++
 .idea/modules.xml                                            |   8 ++++++++
 .idea/vcs.xml                                                |   6 ++++++
 build/bruter                                                 | Bin 0 -> 12375458 bytes
 cmd/bruter/main.go                                           |   3 ++-
 {cmd/bruter => pkg/server}/concurrency.go                    |   6 ++----
 cmd/bruter/routes.go => pkg/server/config.go                 |  39 +++++++++++++++------------------------
 cmd/bruter/middleware.go => pkg/server/middleware/session.go |   5 ++++-
 pkg/server/routes/routes.go                                  |  17 +++++++++++++++++
 pkg/server/server.go                                         |  22 ++++++++++++++++++++++
 11 files changed, 93 insertions(+), 30 deletions(-)
 create mode 100644 .idea/.gitignore
 create mode 100644 .idea/bruter.iml
 create mode 100644 .idea/modules.xml
 create mode 100644 .idea/vcs.xml
 create mode 100755 build/bruter
 rename {cmd/bruter => pkg/server}/concurrency.go (85%)
 rename cmd/bruter/routes.go => pkg/server/config.go (78%)
 rename cmd/bruter/middleware.go => pkg/server/middleware/session.go (66%)
 create mode 100644 pkg/server/routes/routes.go
 create mode 100644 pkg/server/server.go
alessandro@xps:~/Development/bruter$ go run cmd/bruter/*.go -domain example.com
6:54PM INF Scanning IP 93.184.215.14 OK
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x59816e]

goroutine 13 [running]:
github.com/rs/zerolog.(*Logger).should(0x10?, 0x78?)
	/home/alessandro/go/pkg/mod/github.com/rs/[email protected]/log.go:470 +0xe
github.com/rs/zerolog.(*Logger).newEvent(0x0, 0x3, 0x0)
	/home/alessandro/go/pkg/mod/github.com/rs/[email protected]/log.go:446 +0x36
github.com/rs/zerolog.(*Logger).Error(0xc000197aa0?)
	/home/alessandro/go/pkg/mod/github.com/rs/[email protected]/log.go:348 +0x1a
github.com/CyberRoute/bruter/pkg/server.checkError({0x982440, 0xc00040a040})
	/home/alessandro/Development/bruter/pkg/server/config.go:19 +0x33
github.com/CyberRoute/bruter/pkg/server.RunConfiguration.func3()
	/home/alessandro/Development/bruter/pkg/server/config.go:64 +0x85
github.com/CyberRoute/bruter/pkg/server.RunConcurrently.func1(0x0?)
	/home/alessandro/Development/bruter/pkg/server/concurrency.go:12 +0x4c
created by github.com/CyberRoute/bruter/pkg/server.RunConcurrently in goroutine 1
	/home/alessandro/Development/bruter/pkg/server/concurrency.go:10 +0x48
exit status 2

can you check new update? i fix this error

@CyberRoute
Copy link
Owner

Perhaps is due from moving some files from main since before stuff was in main go run cmd/bruter/main.go -domain example.com?

@Nicolas-ggd
Copy link
Contributor Author

Perhaps is due from moving some files from main since before stuff was in main go run cmd/bruter/main.go -domain example.com?

Check latest update, i create struct which is for server/config.go, now we don't have runtime error

@CyberRoute
Copy link
Owner

Sure will do it asap at minute I am not on the computer, will be back later on! Cheers

@Nicolas-ggd
Copy link
Contributor Author

Perhaps is due from moving some files from main since before stuff was in main go run cmd/bruter/main.go -domain example.com?

Also i think that main.go file looks large right now, i think it's better if we create cmd/bruter/app/app.go file which include code from main.go and main.go just calls cmd/bruter/app/app.go function and run it

@CyberRoute
Copy link
Owner

Perhaps is due from moving some files from main since before stuff was in main go run cmd/bruter/main.go -domain example.com?

Also i think that main.go file looks large right now, i think it's better if we create cmd/bruter/app/app.go file which include code from main.go and main.go just calls cmd/bruter/app/app.go function and run it

True the main is absolutely to big

@CyberRoute
Copy link
Owner

Perhaps is due from moving some files from main since before stuff was in main go run cmd/bruter/main.go -domain example.com?

Check latest update, i create struct which is for server/config.go, now we don't have runtime error

Yep it works, I like it! many thanks for contributing @Nicolas-ggd

@CyberRoute
Copy link
Owner

closing #32

@CyberRoute CyberRoute merged commit 1e96a8b into CyberRoute:main Jul 13, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants